<template>
  <Form
    ref="businessForm"
    :model="form"
    :rules="rules"
    @keydown.enter.native="handleSubmit"
    inline
    style="width: 100%">
    <FormItem prop="data" style="width: 250px">
      <Select v-model="form.data" clearable placeholder="请选择资料对接状态">
        <Option value="0">
          未完成
        </Option>
        <Option value="1">
          完成
        </Option>
      </Select>
    </FormItem>
    <FormItem prop="test" style="width: 250px">
      <Select v-model="form.test" clearable placeholder="请选择测试状态">
        <Option value="0">
          未完成
        </Option>
        <Option value="1">
          完成
        </Option>
      </Select>
    </FormItem>
    <FormItem style="float: right">
      <Button @click="handleSubmit" icon="md-search" type="primary">
        搜索
      </Button>
    </FormItem>
  </Form>
</template>
<script>
import {
  mapState,
  mapActions,
  mapMutations
} from 'vuex'
export default {
  name: 'BusinessForm',
  props: {
    dataRules: {
      type: Array,
      default: () => {
        return []
      }
    },
    testRules: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      form: {
        data: '',
        test: ''
      }
    }
  },
  computed: {
    rules () {
      return {
        data: this.dataRules,
        test: this.testRules
      }
    },
    ...mapState({
      project: state => state.operate.project
    })
  },
  methods: {
    handleSubmit () {
      this.$refs.businessForm.validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            data: this.form.data ? parseInt(this.form.data) : '',
            test: this.form.test ? parseInt(this.form.test) : ''
            // muid: this.form.muid ? parseInt(this.form.muid) : ''
          })
        }
      })
    }
  }
}
</script>
